<?php
include('includes/config.php');
include("includes/functions.php");	
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Palangeanu Lucian, 0727 448 535">
	<title>INFP</title>
	<link href="css/style.css" rel="stylesheet">
	<link href="css/start/jquery-ui-1.10.4.custom.css" rel="stylesheet">
	<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
	
	    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	
</head>
<body>
	<div class="container">	
		<div class="header">
			<div id="imgLogo">
				<img src="img/logo.png" alt="INFP | Institutul National pentru Fizica Pamantului" />
			</div>
			<div id="motoLogo">
				<?php echo $_['logo']; ?>
			</div>
      </div>

	<div class="wrapper">
		<h2>Cutremure simtite</h2>
		<table>
			<thead>
			<tr id="capTabel" >
				<th class="data"><b>Data/Ora</b><br/><i>(Ora Romaniei)</i></th>
				<th class="mag"><b>Mag</b><br/><i>&nbsp;</i></th>
				<th class="adancime"><b>Adancime</b><br/><i>(km)</i></th>
				<th class="lat"><b>Lat</b><br/><i>(grade)</i></th>
				<th class="long"><b>Long</b><br/><i>(grade)</i></th>
				<th class="regiune"><b>Regiune</b><br/><i>&nbsp;</i></th>
				<th class="tip">Tip</th>
				<th class="btn"></th>
			</tr>
			</thead>
			<tbody>
			<?php
				$res = mysql_query("SELECT *, (3959 * acos(cos(radians('46.0442')) * cos(radians(lat)) * cos(radians(lon) - radians('24.8871')) + sin(radians('46.0442')) * sin(radians(lat)))) AS distance FROM evenimente HAVING distance < 350 and  tip = 'M' and mag >= 3 order by data_eveniment desc limit 10");
				while($row = mysql_fetch_array($res)):
				
					if(strtotime($row['data_eveniment']) >=  (time() - 3600)){
						$colorRow = 'red';
					}else if(strtotime($row['data_eveniment']) >=  (time() - 3600 * 24)){
						$colorRow = 'orange';
					}else{
						$colorRow = "";
					}
					
					$id_eveniment = $row['id_cutremur'];
					$resColors = mysql_query("select * from feedback where id_eveniment = '$id_eveniment' order by  timp desc");
					if(mysql_num_rows($resColors)>=1){
						$rowColor = mysql_fetch_array($resColors);
						$color_feebak = 'color'.$rowColor['intensitate'];
						$icon = '<i class="icon-bullhorn" title="'.$rowColor['comentariu'].'"></i>';
					}else{
						$color_feebak = "";
						$icon = "";
					}
					
			?>
			
			<tr class="<?php echo $colorRow; ?>  "  id="rowTbl" href="/raspuns/<?php echo $row['id_cutremur']; ?>/">
				<td class="data "><?php echo $row['data_eveniment']; ?> </td>
				<td class="mag "><?php echo $row['mag']; ?></td>
				<td class="adancime "><?php echo $row['adancime']; ?></td>
				<td class="lat "><?php echo $row['lat']; ?></td>
				<td class="long "><?php echo $row['lon']; ?></td>
				<td class="regiune "><?php echo $row['regiune']; ?></td>
				<td class="tip <?php echo $color_feebak; ?>"><?php echo $row['tip']; ?><br /><?php echo $icon; ?></td>
				<td class="btn"><input class="feedbk" href="/raspuns/<?php echo $row['id_cutremur']; ?>/" type="button" value="Lasa feedback"></td>
			</tr>
			<?php endwhile;?>
			
			<tbody>
		</table>
	
	</div>
	</div>
		
</body>
	<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> 
	<script src="../js/jquery-1.10.2.js"></script>
	<script src="../js/jquery-ui-1.10.4.custom.js"></script>
	<script src="../js/main.js"></script>
	<script>
		jQuery.fx.interval = 90;

		$(document).ready(function(){
			$('table tr').click(function(){
				window.location = $(this).attr('href');
				return false;
			});
			$('.feedbk').click(function(){
				window.location = $(this).attr('href');
				return false;
			});
		});
		/*
		pulsate($('.orange'));
		*/
		function hL(){
         $(".orange:first-child").effect( "highlight", 
          {color:"#fff000"}, 1500 );
		
		  $(".red:first-child").effect( "highlight", 
          {color:"red"}, 1500 );
		 }
		 hL()
		 setInterval("hL()",1500)

		  
	</script>

</html>